#include "rviz.h"

#include "rviz/visualization_frame.h"

using namespace rviz;

//**
// *友元函数修改私有变量
// */
// template <typename Tag, typename Tag::factory_ M, typename Tag::tools_ N>
// struct Rob {
//  friend typename Tag::factory_ getFactory() { return M; }
//  friend typename Tag::tools_ getTools() { return N; }
//};

// struct ToolManagerHook {
//  typedef PluginlibFactory<Tool>* ToolManager::*factory_;
//  typedef QList<Tool*> ToolManager::*tools_;
//};

// PluginlibFactory<Tool>* ToolManager::*getFactory();
// QList<Tool*> ToolManager::*getTools();

// template struct Rob<ToolManagerHook, &ToolManager::factory_, &ToolManager::tools_>;

// void* thread(void* tmp) {
//  QLayout* layout = (QLayout*)tmp;

//  rviz::VisualizationFrame* rviz_frame = new rviz::VisualizationFrame();
//  rviz_frame->initialize(QTextStream("./rviz/default.rviz").readAll());
//  layout->addWidget(rviz_frame);
//  return 0;
//}

#include <QTextStream>

void RViz::createRVizFrame(QMainWindow* parent, QLayout* layout) {
  rviz::VisualizationFrame* rviz_frame = new rviz::VisualizationFrame(parent);
  rviz_frame->initialize(QTextStream("./rviz/default.rviz").readAll());
  layout->addWidget(rviz_frame);
  parent->setMenuBar(rviz_frame->menuBar());
}
